package com.flyme.module.base.client.api;


import com.flyme.common.core.model.ResultBody;
import com.flyme.common.core.model.query.PagerInfo;
import com.flyme.common.core.model.query.PqGrid;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;

/**
 * @author: zyf
 * @date: 2019/1/5 19:31
 * @desc:
 */
public interface SysApiRemoteService {

    /**
     * 获取Api资源列表
     */
    @PostMapping("/api")
    PqGrid api(@RequestParam(value = "pagerInfo") PagerInfo pagerInfo, @RequestParam(name = "keyword", required = false) String keyword);


    /**
     * 获取Api资源
     *
     * @param apiId apiId
     * @return
     */
    @GetMapping("/api/{apiId}")
    ResultBody getApi(@PathVariable("apiId") Long apiId);

    /**
     * 添加Api资源
     *
     * @param apiCode     Api编码
     * @param apiName     Api名称
     * @param apiCategory 接口分类
     * @param serviceId   服务ID
     * @param path        请求路径
     * @param status      是否启用
     * @param priority    优先级越小越靠前
     * @param apiDesc     描述
     * @return
     */
    @PostMapping("/api/add")
    ResultBody addApi(@RequestParam(value = "apiCode") String apiCode, @RequestParam(value = "apiName") String apiName, @RequestParam(value = "apiCategory") String apiCategory, @RequestParam(value = "serviceId") String serviceId, @RequestParam(value = "path", required = false, defaultValue = "") String path, @RequestParam(value = "status", defaultValue = "1") Integer status, @RequestParam(value = "priority", required = false, defaultValue = "0") BigDecimal priority, @RequestParam(value = "apiDesc", required = false, defaultValue = "") String apiDesc);

    /**
     * 编辑Api资源
     *
     * @param apiId       ApiID
     * @param apiCode     Api编码
     * @param apiName     Api名称
     * @param apiCategory 接口分类
     * @param serviceId   服务ID
     * @param path        请求路径
     * @param status      是否启用
     * @param priority    优先级越小越靠前
     * @param apiDesc     描述
     * @return
     */
    @PostMapping("/api/update")
    ResultBody updateApi(@RequestParam("apiId") Long apiId, @RequestParam(value = "apiCode") String apiCode, @RequestParam(value = "apiName") String apiName, @RequestParam(value = "apiCategory") String apiCategory, @RequestParam(value = "serviceId") String serviceId, @RequestParam(value = "path", required = false, defaultValue = "") String path, @RequestParam(value = "status", defaultValue = "1") Integer status, @RequestParam(value = "priority", required = false, defaultValue = "0") BigDecimal priority, @RequestParam(value = "apiDesc", required = false, defaultValue = "") String apiDesc);

    /**
     * 更新状态
     *
     * @param apiId  ApiID
     * @param status 状态
     * @return
     */
    @PostMapping("/api/update/status")
    ResultBody updateStatus(@RequestParam("apiId") Long apiId, @RequestParam(value = "status", defaultValue = "1") Integer status);

    /**
     * 移除Api
     *
     * @param apiId ApiID
     * @return
     */
    @PostMapping("/api/remove")
    ResultBody removeApi(@RequestParam("apiId") Long apiId);
}
